package com.example.springmvcdemo4;

import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Q
 * @create 2025-05-26-13:34
 */
@RequestMapping("/response")
@Controller
public class ResponseController {
    //设置Content-Type
    @RequestMapping(value = "/returnJson",produces = "application/json;charset=utf8")
    @ResponseBody
    public String returnJson() {
        return "{\"success\":true}";
    }
    @RequestMapping(value = "/setHeader")
    @ResponseBody
    public String setHeader(HttpServletResponse response) {
        response.setHeader("MyHeader","MyHeaderValue");
        return "设置Header成功";
    }
}
